package com20230213;

import java.util.Arrays;

public class Delete {
    public static void main(String[] args) {
        int[] nums = {2,11,33,44,55,66,277};

        //1.for循环
        int num = 33;
        int[] newNums = new int[nums.length - 1];
        for (int i = 0,start = 0; i < nums.length; i++) {
            if (nums[i] != num) {
                newNums[start] = nums[i];
                System.out.print(newNums[start] +" ");
                start++;


            }

        }
        System.out.println();
        System.out.println(Arrays.toString(newNums));






        //2.arraycopy方法实现
//        System.out.println("源数组为：" + Arrays.toString(nums) );
//        int[] newNums = new int[nums.length - 1];
//        System.arraycopy(nums,0,newNums,0,2);
//        System.out.println(Arrays.toString( newNums));
//        System.arraycopy(nums,3,newNums,2,4);
//        System.out.println(Arrays.toString( newNums));



    }
}
